package com.hx.voice.recognition.admin.rpc;

import com.hx.voice.recognition.admin.manager.entity.GateLog;
import com.hx.voice.recognition.admin.manager.service.IGateLogService;
import com.hx.voice.recognition.api.vo.log.LogInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @descripe：为网关保存日志提供服务
 * @company：南京华讯方舟通讯设备有限公司
 * @author：zhoujinbing
 * @time：2019/6/13 10:49
 * @version：V1.0
 */
@RestController
@RequestMapping("api")
public class LogRest {

    @Autowired
    private IGateLogService gateLogService;

    /**
     * @description 保存操作日志
     * @method  saveLog
     * @param  [logInfo]
     * @return void
     * @date: 2019/6/21 17:29
     * @author:zhoujinbing
     */
    @RequestMapping(value = "/log/save",method = RequestMethod.POST)
    public void saveLog(@RequestBody LogInfo logInfo)
    {
        GateLog log = new GateLog();
        BeanUtils.copyProperties(logInfo,log);
        log.setCrtTime(new Date(logInfo.getCrtTime()));
        gateLogService.save(log);

    }


}